<template>
  <div id="app">
    <transition>
      <router-view></router-view>
    </transition>

    <!-- 底部区域 -->

    <nav :class="['mui-bar','mui-bar-tab',{'colorbg':iscolorbg}]">
      <router-link class="mui-tab-item-lkx" to="/home">
        <span class="mui-icon homediy"></span>
        <span class="mui-tab-label">
          <img src="./assets/gb.png" alt="color">
        </span>
      </router-link>
      <router-link class="mui-tab-item-lkx" to="/dataview">
        <span class="mui-icon dataview"></span>
        <span class="mui-tab-label">
          <img src="./assets/gb.png" alt="color">
        </span>
      </router-link>
      <router-link class="mui-tab-item-lkx" to="/maintenance">
        <span class="mui-icon maintenance"></span>
        <span class="mui-tab-label">
          <img src="./assets/gb.png" alt="color">
        </span>
      </router-link>
      <router-link class="mui-tab-item-lkx" to="/wd">
        <span class="mui-icon sw"></span>
        <span class="mui-tab-label">
          <img src="./assets/gb.png" alt="color">
        </span>
      </router-link>
      <router-link class="mui-tab-item-lkx" to="/kf">
        <span class="mui-icon kf"></span>
        <span class="mui-tab-label">
          <img src="./assets/gb.png" alt="color">
        </span>
      </router-link>
    </nav>
  </div>
</template>

<script>
export default {
  name: "App",
  data() {
    return {
      paths:this.$route.path,
      "mui-bar":true,
      "mui-bar-tab":true,
      "iscolorbg":false
    };
  },
  methods: {
   
  },
  created(){
  // 只有页面在home页面 底部的颜色才是蓝色,这里是页面如果一打开就显示蓝色，
  //  paths:this.$route.path
   if(this.paths==='/home'){
     this.iscolorbg=true
   }
  },
  watch: {
    //监听 只有页面在home页面 底部的颜色才是蓝色，这是这是切换的时候。
    "$route.path": function(newVal, oldVal) {
      if (newVal === "/home") {
        this.iscolorbg=true
      }
      else{
        this.iscolorbg=false
      }
    }
  }
};
</script>

<style lang="scss">
html {
  background: #ffffff;
}
#app {
  font-family: "Microsoft YaHei", "Avenir", Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  
  padding-bottom: 0.5rem;
  background: #fff;
  overflow-x: hidden;
}
.mint-header {
  z-index: 99;
  height: 0.63rem;
  background: #424578;
}
.mint-header-title {
  font-size: 0.16rem;
  padding: 0.1rem 0;
}
.mint-header .mint-button img {
  height: 100%;
}

/* 改类名解决tabbar无法切换的问题 修改与tab-item类相关的*/

.mui-tab-label {
  position: relative;
  width: 100%;
  height: 0.14rem;
}

.router-link-active .mui-tab-label img {
  position: absolute;
  left: 0;
  bottom: -0.24rem;
  width: 100%;
  z-index: 99;
}

.mui-bar-tab .mui-tab-item-lkx {
  display: table-cell;
  overflow: hidden;
  width: 1%;
  height: 0.5rem;
  text-align: center;
  vertical-align: middle;
  white-space: nowrap;
  text-overflow: ellipsis;
  color: #929292;
}
.mui-bar-tab .mui-tab-item-lkx .mui-icon {
  top: 0.08rem;
  width: 0.3rem;
  height: 0.3rem;
  padding-top: 0;
  padding-bottom: 0;
}
/* 自定义图标 */
.mui-bar-tab .mui-tab-item-lkx {
  .homediy {
    background: url("./assets/sy1.png") no-repeat center;
    background-size: 100% 100%;
  }
  .dataview {
    background: url("./assets/sj.png") no-repeat center;
    background-size: 100% 100%;
  }
  .maintenance {
    background: url("./assets/wb.png") no-repeat center;
    background-size: 100% 100%;
  }
  .sw {
    background: url("./assets/sw.png") no-repeat center;
    background-size: 100% 100%;
  }
  .kf {
    background: url("./assets/kf.png") no-repeat center;
    background-size: 100% 100%;
  }
}
// 选中状态图标
.mui-bar-tab .router-link-active {
  .homediy {
    background: url("./assets/sy.png") no-repeat center;
    background-size: 100% 100%;
  }
  .dataview {
    background: url("./assets/sj1.png") no-repeat center;
    background-size: 100% 100%;
  }
  .maintenance {
    background: url("./assets/wb1.png") no-repeat center;
    background-size: 100% 100%;
  }
  .sw {
    background: url("./assets/sw1.png") no-repeat center;
    background-size: 100% 100%;
  }
  .kf {
    background: url("./assets/kf1.png") no-repeat center;
    background-size: 100% 100%;
  }
}
.mui-bar-tab {
  color: #283351;
}
.mui-bar-tab .mui-tab-item-lkx .mui-icon ~ .mui-tab-label {
  font-size: 0.11rem;
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
}
input[type="button"]:enabled:active,
input[type="button"].mui-active:enabled,
input[type="submit"]:enabled:active,
input[type="submit"].mui-active:enabled,
input[type="reset"]:enabled:active,
input[type="reset"].mui-active:enabled,
button:enabled:active,
button.mui-active:enabled,
.mui-btn:enabled:active,
.mui-btn.mui-active:enabled {
  background-color: transparent;
}
.colorbg {
  //顶部图片 是否这个颜色
  background: #424578 !important;
}

//动画效果
/* 每个tabbar组件的切换效果 */
.v-enter {
  opacity: 0;
  transform: translateX(100%);
}

.v-leave-to {
  opacity: 0;
  transform: translateX(-100%);
  position: fixed;
  top:0;
}

.v-enter-active,
.v-leave-active {
  transition: all 0.3s ease;
}
</style>
